## Ryan Copus and Ryan Hübert
## Measuring How Much Judges Matter for Case Outcomes
## Journal of Law and Courts

# Note to reader: please review the README for important information about 
# software and other requirements

# Required packages
libs <- c("parallel", "ade4", "here", "h2o", "xgboost", "tidyverse", "pROC", "wfe")

# Check if packages installed
for(lib in libs){
  if (!lib %in% rownames(installed.packages())) { 
    install.packages(lib) 
  }
}

# Test if R knows the correct working directory
expected <- file.path("Code/_config.R")
if (!file.exists(here::here(expected))) {
  stop("It looks like you're running the script from outside the replication folder. Please run from within the replication folder, or manually set your working directory to the replication folder.")
}

# Set working directory to `here`
# Note: root folder contains a file .here that points R to the correct working
# directory
setwd(here::here())